<template>
  {{ sj
  }}<el-button
    type="primary"
    icon="el-icon-edit"
    circle
    @click="changeVuex"
  ></el-button>
  <el-table :data="tableData" style="width: 100%">
    <el-table-column prop="id" label="#" width="100"> </el-table-column>
    <el-table-column prop="p_name" label="姓名"> </el-table-column>
    <el-table-column prop="p_sex" label="性别"> </el-table-column>
    <el-table-column prop="p_age" label="年龄"> </el-table-column>
    <el-table-column prop="p_hobby" label="爱好"> </el-table-column>
    <el-table-column label="日期" width="180">
      <template #default="scope">
        <el-button
          type="primary"
          icon="el-icon-edit"
          circle
          @click="goEdit(scope.row)"
        ></el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
const axios = require("axios");
export default {
  data() {
    return {
      tableData: [],
      sj: "",
      xsn:"",
      xsn2:"",
      cxx2:""
    };
  },
  mounted() {
    this.getData();
    this.sj = this.$store.state.vuextest;
  },
  methods: {
    getData() {
      let _this = this;
      axios
        .get("https://localhost:44367/api/Person/getlist")
        .then(function (response) {
          _this.tableData = response.data;
        });
    },
    goEdit(row) {
      this.$router.push({ name: "Edit", params: { row: JSON.stringify(row) } });
      console.log(row);
    },
    changeVuex() {
      this.$store.commit("changeVuextest", "还行");
      var a = this.$store.state.vuextest;
      console.log(a);
      this.sj = a;
    },
  },
};
</script>

<style></style>
